<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
		<title>搜索_结果</title>
		<link type="text/css" href="css/reset.css" rel="stylesheet"/>
		<link type="text/css" rel="stylesheet" href="css/all.css" />
		<script src="js/flexible.min.js"></script>
		<script src="js/jquery.1.11.3.min.js"></script>
		<script src="js/main.js"></script>
	</head>
	<body style="background: #e5e5e5;">
		<!------------------------------------------------搜索头部------------------------------------------->
		<div class="select_head">
			<a href="index.html">
				<img src="img/img15.png" class="back">
			</a>
			<div class="select_d">
				<img src="img/img14.png" class="select_d_img">
				<input type="text" class="select_d_btn" id="select_d_btn" name="select_d_btn" placeholder="搜索店铺商品" />
			</div>
			<a href="#">
				<p class="select_text">搜索</p>
			</a>
		</div>
		<!------------------------------------------------搜索内容------------------------------------------->
		<div class="select_con">
			<div class="j-fooditem fooditem clearfix bac_f">
				<div class="select_con_img">
					<img src="img/img16.png"/>
				</div>
				<div class="food-cont-wrap">
					<div class="food-cont">
						<div class="foodname">葡式蛋挞（经典）2只装</div>
						<div class="food-content-sub yuexiao"> 
							<span>月售&nbsp;120</span> 
						</div>
						<div class="food-price-region">  
							<span class="food-price">¥18</span> 
						</div>
						<div class="j-item-console foodop clearfix"> 
							<a class="j-add-item add-food" href="javascript:;">
								<i class="icon i-add-food"><img src="img/jia.png"/></i>
							</a> 
							<span class="j-item-num foodop-num" style="display:none">0</span>
							<a class="j-remove-item remove-food" style="display:none" href="javascript:;">
								<i class="icon i-remove-food"><img src="img/jian.png"/></i>
							</a> 
						</div>
					</div>
				</div>
			</div>
			<div class="j-fooditem fooditem clearfix bac_f">
				<div class="select_con_img">
					<img src="img/img16.png"/>
				</div>
				<div class="food-cont-wrap">
					<div class="food-cont">
						<div class="foodname">葡式蛋挞（经典）2只装</div>
						<div class="food-content-sub yuexiao"> 
							<span>月售&nbsp;120</span> 
						</div>
						<div class="food-price-region">  
							<span class="food-price">¥18</span> 
						</div>
						<div class="j-item-console foodop clearfix"> 
							<a class="j-add-item add-food" href="javascript:;">
								<i class="icon i-add-food"><img src="img/jia.png"/></i>
							</a> 
							<span class="j-item-num foodop-num" style="display:none">0</span>
							<a class="j-remove-item remove-food" style="display:none" href="javascript:;">
								<i class="icon i-remove-food"><img src="img/jian.png"/></i>
							</a> 
						</div>
					</div>
				</div>
			</div>
		</div>
		<!------------------------------------------------购物车--------------------------------------------------------->
		<div id="cart" class="cart">
            <div class="cart-tip">
                <div class="j-cart-icon cart-icon">
                    <i class="j-ico-cart ico-cart"></i>
                    <div class="j-cart-num cart-num">0</div>
                </div>
                <div class="ssjg_num">￥25</div>
                 <a href="#">
            	<p class="ssjg_tjdd">提交订单</p>
            </a>
            </div>
           
        </div>
	</body>
</html>
<script>
		$(function(){
				$('.menu-tabs a').click(function(){
					$(this).addClass('selected').siblings().removeClass('selected');
					console.log(this);
				});
			// 数量减
			$(".remove-food").click(function() {
				
				
				var num=parseInt($(this).parent().children(".foodop-num").text()); //得到商品的数量
			  	console.log(num);
			  	var sum=parseInt($(".cart-num").text());
			  	sum=num-1;
			  	$('.cart-num').text(sum);
				
				
				
				var t = $(this).parent().find('.foodop-num');
				t.text(parseInt(t.text()) - 1);
				if (t.text() <= 0) {
					t.hide();
					t.parent().find('.remove-food').hide();
					$('.cart .ico-cart').css('background-image','url(img/shop.png)');
					$('.cart .cart-num').hide();
				}
				
			});
			// 数量加
			$(".add-food").click(function() {
				
				var num=parseInt($(this).parent().children(".foodop-num").text()); //得到商品的数量
			  	console.log(num);
			  	var sum=parseInt($(".cart-num").text());
			  	sum=num+1;
			  	$('.cart-num').text(sum );
				
				
				$(this).parent().find('.foodop-num').show();
				$(this).parent().find('.remove-food').show();
				$('.cart .ico-cart').css('background-image','url(img/shop1.png)');
				$('.cart .cart-num').show();
				var t = $(this).parent().find('.foodop-num');
				t.html(parseInt(t.html()) + 1);
				if (t.text() <= 1) {
					t.text(1);
				}
				
			});
			
		});
		
	</script>
